class Solution {
public:
    string LeftRotateString(string str, int x) {
        if(str.empty() || x < 0)
			return str;
		int length = str.size();
		reverse(0,x-1,str);
		reverse(x,length-1,str);
		reverse(0,length-1,str);
		return str;
    }

    void reverse(int i,int j,string &arr)
	{
		while(i<j)
		{
			char temp = arr[i];
			arr[i] = arr[j];
			arr[j] = temp;
			++i;
			--j;
		}
	}

};